package com.example.calculator.fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.Navigation
import com.example.calculator.MyViewModel

import com.example.calculator.R
import com.example.calculator.databinding.FragmentTitleBinding
import com.example.calculator.databinding.FragmentWinBinding

/**
 * A simple [Fragment] subclass.
 */
class WinFragment : Fragment() {

    private var mViewModel:MyViewModel?=null
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        //
        mViewModel= ViewModelProvider(activity!!)[MyViewModel::class.java]
        mViewModel!!.save()
//        mViewModel!!.getCurrentScore().value=0
        //
        var databinding: FragmentWinBinding =
            DataBindingUtil.inflate(inflater,R.layout.fragment_win,container,false)
        databinding.data=mViewModel
        databinding.lifecycleOwner=activity
        databinding.button14.setOnClickListener(View.OnClickListener {
            Navigation.findNavController(it)
                .navigate(R.id.action_winFragment_to_titleFragment)
        })
        // Inflate the layout for this fragment
        return databinding.root
    }

}
